import { Component, OnInit, Input, EventEmitter, Output, HostListener } from '@angular/core';

@Component({
  selector: 'app-checkbox',
  templateUrl: './checkbox.component.html',
  styleUrls: ['./checkbox.component.css']
})
export class CheckboxComponent implements OnInit {
  @Input() checked = false
  @Output() checkeChange = new EventEmitter<boolean>()

  constructor() { }

  ngOnInit() {
    console.log('checked:' + this.checked)
  }
  
  @HostListener('click', ['$event'])
  onClick(e: Event) {
    e.preventDefault()
    this.checked = !this.checked
    this.checkeChange.emit(this.checked)
  }

}
